package exam.business.service;

import java.util.Date;

import exam.common.constant.ResultPort;
import exam.common.key.KeySubQuestion;
import exam.common.util.NullCheckUtil;
import exam.model.dao.TSubQuestionDAO;
import exam.model.entity.TSubQuestionEntity;
import exam.system.business.AbstractService;
import exam.system.business.BusinessServiceInfo;
/**
 * <p>SubQuestionUpdateService</p>
 * 
 * @author Phong
 * @version 20/5/2012
 */
public class SubQuestionUpdateService extends AbstractService{
	private TSubQuestionDAO tSubQuestionDAO = new TSubQuestionDAO();
	@Override
	public String executeService(BusinessServiceInfo serviceInfo)
			throws Exception {
		String port = null;
		// Lay thong tin danh muc cau hoi tu serviceInfo
		TSubQuestionEntity tSubQuestionEntity = serviceInfo.getObject(KeySubQuestion.T_SUB_QUESTION_ENTITY);
		if(NullCheckUtil.isNotNull(tSubQuestionEntity)) {
			// set lai ngay update
			tSubQuestionEntity.setUpdateDate(new Date());
			// goi phuong thuc update
			int update = tSubQuestionDAO.updateSubQuestion(tSubQuestionEntity);
			if(update == 0) {
				port = ResultPort.FAIL;
			} else {
				port = ResultPort.SUCCESS;
			}
		}
		return port;
	}

}
